home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / wbgames / sorttiles / sorttiles.mod < prev    next >
Text File  |  1996-04-07  |  14KB  |  532 lines

  1. MODULE SortTiles;
  2.  
  3. IMPORT
  4.        y:SYSTEM,
  5.        g:Graphics,
  6.        d:Dos,
  7.        e:Exec,
  8.        fs:FileSystem,
  9.        Random,
  10.        mt:MathTrans,
  11.        gt:GadTools,
  12.        I:Intuition,
  13.        conv:Conversions,
  14.        io,
  15.        wb:Workbench,
  16.        ic:Icon,
  17.        ol:OberonLib,
  18.        u:Utility;
  19.  
  20. TYPE
  21.      strg=ARRAY 100 OF CHAR;
  22.      MsgT=ARRAY 4 OF strg;
  23.  
  24. CONST
  25.      Messies=MsgT("SortTiles","Lets get faster....","Click to start",
  26.      "Game Over");
  27.  
  28.  
  29.  
  30. TYPE TileT=ARRAY 5 OF INTEGER;
  31.      TileA=ARRAY 5 OF TileT;
  32.      TSet =ARRAY 5 OF INTEGER;
  33.      CSet =ARRAY 6 OF INTEGER;
  34.      NmSt =ARRAY 7 OF INTEGER;
  35.      NmSs =ARRAY 10 OF NmSt;
  36.  
  37. CONST
  38.      Tiles=TileA(
  39.               0 , 1, 5,10,15,
  40.               2 , 3, 4, 9,14,
  41.               6 , 7,11,12,17,
  42.               8 ,13,18,19,24,
  43.               16,20,21,22,23
  44.               );
  45.  
  46.      Nums =NmSs(
  47.               1,1,1,0,1,1,1,
  48.               0,0,1,0,0,1,0,
  49.               1,0,1,1,1,0,1,
  50.               1,0,1,1,0,1,1,
  51.               0,1,1,1,0,1,0,
  52.               1,1,0,1,0,1,1,
  53.               1,1,0,1,1,1,1,
  54.               1,0,1,0,0,1,0,
  55.               1,1,1,1,1,1,1,
  56.               1,1,1,1,0,1,1);
  57.  
  58.  
  59.  
  60. VAR
  61.      Scr:I.ScreenPtr;
  62.      Win:I.WindowPtr;
  63.      helpname:strg;
  64.      iwx,iwy,iwh,iww:INTEGER;
  65.      wx,wy,wh,ww:INTEGER;
  66.      ox,oy,sx,sy:INTEGER;
  67.      sets:ARRAY 5 OF TSet;
  68.      Colors:CSet;
  69.      scor,bonus,tims,timf,tim,timo,ns,nc:INTEGER;
  70.      high,Smsg,Smsgo:INTEGER;
  71.  
  72. PROCEDURE OpenWindow;
  73. BEGIN;
  74. Win:=I.OpenWindowTagsA(NIL,I.waInnerWidth,iww,I.waInnerHeight,iwh,
  75.  I.waLeft,iwx,I.waTop,iwy,
  76.  I.waTitle,y.ADR("SortTiles"),
  77.  I.waIDCMP,LONGSET{I.closeWindow,I.newSize,I.mouseButtons,
  78.     I.intuiTicks,I.inactiveWindow},
  79.  I.waFlags,LONGSET{I.windowDepth,I.windowDrag,I.windowSizing,
  80.     I.windowClose,I.activate,I.reportMouse,I.rmbTrap},
  81.  I.waMaxWidth,2048,I.waMaxHeight,2048,
  82.  I.waMinWidth,120,I.waMinHeight,40,
  83.  u.done);
  84. END OpenWindow;
  85.  
  86. PROCEDURE UpdMsg;
  87. BEGIN;
  88. IF Smsg#Smsgo THEN
  89.  Smsgo:=Smsg;
  90.  I.SetWindowTitles(Win,y.ADR(Messies[Smsg]),-1);
  91. END;
  92. END UpdMsg;
  93.  
  94. PROCEDURE CalcWin;
  95. BEGIN;
  96. ox:=Win.borderLeft;
  97. oy:=Win.borderTop;
  98. wx:=Win.leftEdge;
  99. wy:=Win.topEdge;
  100. ww:=Win.width-Win.borderLeft-Win.borderRight;
  101. wh:=Win.height-Win.borderTop-Win.borderBottom;
  102. sx:=ww DIV 31;
  103. sy:=wh DIV 13;
  104. END CalcWin;
  105.  
  106. PROCEDURE Save;
  107. VAR f:fs.File;
  108. BEGIN;
  109. CalcWin;
  110. iwx:=wx;iwy:=wy;
  111. iww:=ww;iwh:=wh;
  112. IF fs.Open(f,"ENVARC:SortTiles.prefs",TRUE) THEN
  113.  IF fs.Write(f,iwx) THEN END;
  114.  IF fs.Write(f,iwy) THEN END;
  115.  IF fs.Write(f,iww) THEN END;
  116.  IF fs.Write(f,iwh) THEN END;
  117.  IF fs.Write(f,high) THEN END;
  118.  IF fs.Close(f) THEN END;
  119. END;
  120. END Save;
  121.  
  122. PROCEDURE Load;
  123. VAR f:fs.File;
  124. BEGIN;
  125. IF fs.Open(f,"ENVARC:SortTiles.prefs",FALSE) THEN
  126.  IF fs.Read(f,iwx) THEN END;
  127.  IF fs.Read(f,iwy) THEN END;
  128.  IF fs.Read(f,iww) THEN END;
  129.  IF fs.Read(f,iwh) THEN END;
  130.  IF fs.Read(f,high) THEN END;
  131.  IF fs.Close(f) THEN END;
  132. END;
  133. END Load;
  134.  
  135. PROCEDURE GetToolTypes;
  136. VAR This:d.ProcessPtr;
  137.     wbm:wb.WBStartupPtr;
  138.     sptr:e.STRPTR;
  139.     MyIcon:wb.DiskObjectPtr;
  140.     OCurrentDir:d.FileLockPtr;
  141.     li:LONGINT;
  142. BEGIN;
  143. This:=y.VAL(d.ProcessPtr,ol.Me);
  144. IF ol.wbStarted THEN
  145.  wbm:=ol.wbenchMsg;
  146.  OCurrentDir:=This.currentDir;
  147.  y.SETREG(0,d.CurrentDir(wbm.argList[0].lock));
  148.  MyIcon := ic.GetDiskObject(wbm.argList[0].name^);
  149.  y.SETREG(0,d.CurrentDir(OCurrentDir));
  150.  IF MyIcon#NIL THEN
  151.   sptr := ic.FindToolType(MyIcon.toolTypes,"HELPFILE");
  152.   IF sptr#NIL THEN COPY(sptr^,helpname);END;
  153.   sptr := ic.FindToolType(MyIcon.toolTypes,"COL1");
  154.   IF sptr#NIL THEN IF conv.StringToInt(sptr^,li) THEN Colors[1]:=SHORT(li);END;END;
  155.   sptr := ic.FindToolType(MyIcon.toolTypes,"COL2");
  156.   IF sptr#NIL THEN IF conv.StringToInt(sptr^,li) THEN Colors[2]:=SHORT(li);END;END;
  157.   sptr := ic.FindToolType(MyIcon.toolTypes,"COL3");
  158.   IF sptr#NIL THEN IF conv.StringToInt(sptr^,li) THEN Colors[3]:=SHORT(li);END;END;
  159.   sptr := ic.FindToolType(MyIcon.toolTypes,"COL4");
  160.   IF sptr#NIL THEN IF conv.StringToInt(sptr^,li) THEN Colors[4]:=SHORT(li);END;END;
  161.   sptr := ic.FindToolType(MyIcon.toolTypes,"COL5");
  162.   IF sptr#NIL THEN IF conv.StringToInt(sptr^,li) THEN Colors[5]:=SHORT(li);END;END;
  163.   ic.FreeDiskObject(MyIcon);
  164.  END;
  165. END;
  166. END GetToolTypes;
  167.  
  168. PROCEDURE Init;
  169. VAR n,m:INTEGER;
  170. BEGIN;
  171. iwx:=0;iwy:=0;iwh:=130;iww:=310;high:=0;
  172. Colors:=CSet(0,1,2,3,4,5);
  173. helpname:="PROGDIR:SortTiles.shortdoc";
  174. GetToolTypes;
  175. Load;
  176. OpenWindow;
  177. FOR n:=0 TO 4 DO FOR m:=0 TO 4 DO sets[n,m]:=-1;END;END;
  178. sx:=10;sy:=10;
  179. ox:=10;oy:=10;
  180. nc:=2;ns:=2;
  181. timf:=30;bonus:=5;
  182. CalcWin;
  183. END Init;
  184.  
  185.  PROCEDURE RenderNum(c,n,x,y,p:INTEGER);
  186.  BEGIN;
  187.   g.SetAPen(Win.rPort,c);
  188.   IF Nums[n,0]=1 THEN
  189.    g.Move(Win.rPort,x+ox+(13+p*2)*sx,y+oy+9*sy);
  190.    g.Draw(Win.rPort,x+ox+(14+p*2)*sx,y+oy+9*sy);
  191.   END;
  192.   IF Nums[n,1]=1 THEN
  193.    g.Move(Win.rPort,x+ox+(13+p*2)*sx,y+oy+9*sy);
  194.    g.Draw(Win.rPort,x+ox+(13+p*2)*sx,y+oy+10*sy);
  195.   END;
  196.   IF Nums[n,2]=1 THEN
  197.    g.Move(Win.rPort,x+ox+(14+p*2)*sx,y+oy+9*sy);
  198.    g.Draw(Win.rPort,x+ox+(14+p*2)*sx,y+oy+10*sy);
  199.   END;
  200.   IF Nums[n,3]=1 THEN
  201.    g.Move(Win.rPort,x+ox+(13+p*2)*sx,y+oy+10*sy);
  202.    g.Draw(Win.rPort,x+ox+(14+p*2)*sx,y+oy+10*sy);
  203.   END;
  204.   IF Nums[n,4]=1 THEN
  205.    g.Move(Win.rPort,x+ox+(13+p*2)*sx,y+oy+10*sy);
  206.    g.Draw(Win.rPort,x+ox+(13+p*2)*sx,y+oy+11*sy);
  207.   END;
  208.   IF Nums[n,5]=1 THEN
  209.    g.Move(Win.rPort,x+ox+(14+p*2)*sx,y+oy+10*sy);
  210.    g.Draw(Win.rPort,x+ox+(14+p*2)*sx,y+oy+11*sy);
  211.   END;
  212.   IF Nums[n,6]=1 THEN
  213.    g.Move(Win.rPort,x+ox+(13+p*2)*sx,y+oy+11*sy);
  214.    g.Draw(Win.rPort,x+ox+(14+p*2)*sx,y+oy+11*sy);
  215.   END;
  216.  END RenderNum;
  217.  
  218. PROCEDURE RenderBorders;
  219. VAR n:INTEGER;
  220. BEGIN;
  221. FOR n:=0 TO 4 DO
  222.  g.SetAPen(Win.rPort,2);
  223.  g.Move(Win.rPort,ox+(n*6+1)*sx-1,oy+6*sy-1);
  224.  g.Draw(Win.rPort,ox+(n*6+1)*sx-1,oy+sy-1);
  225.  g.Draw(Win.rPort,ox+(n*6+6)*sx-1,oy+sy-1);
  226.  g.SetAPen(Win.rPort,1);
  227.  g.Move(Win.rPort,ox+(n*6+1)*sx,oy+6*sy);
  228.  g.Draw(Win.rPort,ox+(n*6+6)*sx,oy+6*sy);
  229.  g.Draw(Win.rPort,ox+(n*6+6)*sx,oy+sy);
  230. END;
  231.  g.SetAPen(Win.rPort,1);
  232.  g.Move(Win.rPort,ox+sx-1,oy+12*sy-1);
  233.  g.Draw(Win.rPort,ox+sx-1,oy+7*sy-1);
  234.  g.Draw(Win.rPort,ox+6*sx-1,oy+7*sy-1);
  235.  g.SetAPen(Win.rPort,2);
  236.  g.Move(Win.rPort,ox+sx,oy+12*sy);
  237.  g.Draw(Win.rPort,ox+6*sx,oy+12*sy);
  238.  g.Draw(Win.rPort,ox+6*sx,oy+7*sy);
  239.  g.SetAPen(Win.rPort,2);
  240.  g.Move(Win.rPort,ox+13*sx-1,oy+8*sy-1);
  241.  g.Draw(Win.rPort,ox+13*sx-1,oy+7*sy-1);
  242.  g.Draw(Win.rPort,ox+30*sx-1,oy+7*sy-1);
  243.  g.SetAPen(Win.rPort,1);
  244.  g.Move(Win.rPort,ox+13*sx,oy+8*sy-1);
  245.  g.Draw(Win.rPort,ox+30*sx,oy+8*sy-1);
  246.  g.Draw(Win.rPort,ox+30*sx,oy+7*sy);
  247.  
  248. g.SetAPen(Win.rPort,2);
  249. g.DrawEllipse(Win.rPort,ox-1+7*sx+sx*5 DIV 2,oy-1+7*sy+sy*5 DIV 2,sx*5 DIV 2,sy*5 DIV 2);
  250. g.SetAPen(Win.rPort,1);
  251. g.DrawEllipse(Win.rPort,1+ox+7*sx+sx*5 DIV 2,1+oy+7*sy+sy*5 DIV 2,sx*5 DIV 2,sy*5 DIV 2);
  252. g.SetAPen(Win.rPort,3);
  253. g.DrawEllipse(Win.rPort,ox+7*sx+sx*5 DIV 2,oy+7*sy+sy*5 DIV 2,sx*5 DIV 2,sy*5 DIV 2);
  254. END RenderBorders;
  255.  
  256. PROCEDURE RenderTile(n,c,x,y:INTEGER);
  257. VAR px,py,cn:INTEGER;
  258. BEGIN;
  259. g.SetAPen(Win.rPort,Colors[c+1]);
  260. FOR cn:=0 TO 4 DO
  261.  px:=Tiles[n,cn] MOD 5 * sx;
  262.  py:=Tiles[n,cn] DIV 5 * sy;
  263.  g.RectFill(Win.rPort,ox+px+x,oy+py+y,ox+px+x+sx-1,oy+py+y+sy-1);
  264. END;
  265. END RenderTile;
  266.  
  267. PROCEDURE RenderBonus;
  268. VAR n:INTEGER;
  269. BEGIN;
  270. g.SetAPen(Win.rPort,3);
  271. FOR n:=1 TO 17 DO
  272.  IF bonus<n THEN g.SetAPen(Win.rPort,0);END;
  273.  g.RectFill(Win.rPort,ox+(12+n)*sx,oy+7*sy,ox+(13+n)*sx-2,oy+8*sy-2);
  274. END;
  275. END RenderBonus;
  276.  
  277. PROCEDURE RenderTiles;
  278. VAR n,m,c:INTEGER;
  279. BEGIN;
  280. FOR n:=0 TO 4 DO
  281.  FOR m:=0 TO 4 DO
  282.   c:=sets[n,m];
  283.   RenderTile(m,c,sx+(sx*6)*n,sy);
  284.  END;
  285. END;
  286. END RenderTiles;
  287.  
  288. PROCEDURE RenderNext;
  289. BEGIN;
  290.  RenderTile(0,-1,sx,sy*7);
  291.  RenderTile(1,-1,sx,sy*7);
  292.  RenderTile(2,-1,sx,sy*7);
  293.  RenderTile(3,-1,sx,sy*7);
  294.  RenderTile(4,-1,sx,sy*7);
  295.  RenderTile(ns,nc,sx,sy*7);
  296. END RenderNext;
  297.  
  298. PROCEDURE NewTile;
  299. VAR n,m:INTEGER;
  300.     cn:ARRAY 5 OF INTEGER;
  301. BEGIN;
  302. nc:=Random.RND(5);
  303. ns:=Random.RND(5);
  304. IF Random.RND(100)<50 THEN
  305.  FOR n:=0 TO 4 DO cn[n]:=0;END;
  306.  FOR n:=0 TO 4 DO
  307.   FOR m:=0 TO 4 DO
  308.    IF sets[m,n]#-1 THEN INC(cn[n]);END;
  309.   END;
  310.  END;
  311.  m:=0;
  312.  FOR n:=1 TO 4 DO
  313.   IF cn[n]<cn[m] THEN m:=n;END;
  314.  END;
  315.  ns:=m;
  316. END;
  317. RenderNext;
  318. END NewTile;
  319.  
  320. PROCEDURE RenderClock;
  321. BEGIN;
  322. g.SetAPen(Win.rPort,0);
  323. g.Move(Win.rPort,ox-1+7*sx+sx*5 DIV 2,oy-1+7*sy+sy*5 DIV 2);
  324. g.Draw(Win.rPort,ox-1+7*sx+sx*5 DIV 2+SHORT(ENTIER(mt.Cos(0.0031415*timo)*sx*1.5)),oy-1+7*sy+sy*5 DIV 2+SHORT(ENTIER(mt.Sin(0.0031415*timo)*sx*1.5)));
  325. g.Move(Win.rPort,ox+1+7*sx+sx*5 DIV 2,oy+1+7*sy+sy*5 DIV 2);
  326. g.Draw(Win.rPort,ox+1+7*sx+sx*5 DIV 2+SHORT(ENTIER(mt.Cos(0.0031415*timo)*sx*1.5)),oy+1+7*sy+sy*5 DIV 2+SHORT(ENTIER(mt.Sin(0.0031415*timo)*sx*1.5)));
  327. g.Move(Win.rPort,ox+7*sx+sx*5 DIV 2,oy+7*sy+sy*5 DIV 2);
  328. g.Draw(Win.rPort,ox+7*sx+sx*5 DIV 2+SHORT(ENTIER(mt.Cos(0.0031415*timo)*sx*1.5)),oy+7*sy+sy*5 DIV 2+SHORT(ENTIER(mt.Sin(0.0031415*timo)*sx*1.5)));
  329. g.SetAPen(Win.rPort,2);
  330. g.Move(Win.rPort,ox-1+7*sx+sx*5 DIV 2,oy-1+7*sy+sy*5 DIV 2);
  331. g.Draw(Win.rPort,ox-1+7*sx+sx*5 DIV 2+SHORT(ENTIER(mt.Cos(0.0031415*tim)*sx*1.5)),oy-1+7*sy+sy*5 DIV 2+SHORT(ENTIER(mt.Sin(0.0031415*tim)*sx*1.5)));
  332. g.SetAPen(Win.rPort,1);
  333. g.Move(Win.rPort,ox+1+7*sx+sx*5 DIV 2,oy+1+7*sy+sy*5 DIV 2);
  334. g.Draw(Win.rPort,ox+1+7*sx+sx*5 DIV 2+SHORT(ENTIER(mt.Cos(0.0031415*tim)*sx*1.5)),oy+1+7*sy+sy*5 DIV 2+SHORT(ENTIER(mt.Sin(0.0031415*tim)*sx*1.5)));
  335. g.SetAPen(Win.rPort,3);
  336. g.Move(Win.rPort,ox+7*sx+sx*5 DIV 2,oy+7*sy+sy*5 DIV 2);
  337. g.Draw(Win.rPort,ox+7*sx+sx*5 DIV 2+SHORT(ENTIER(mt.Cos(0.0031415*tim)*sx*1.5)),oy+7*sy+sy*5 DIV 2+SHORT(ENTIER(mt.Sin(0.0031415*tim)*sx*1.5)));
  338. END RenderClock;
  339.  
  340. PROCEDURE RenderHScor;
  341. VAR n,m,t:INTEGER;
  342. BEGIN;
  343.  t:=high;
  344.  g.SetAPen(Win.rPort,0);
  345.  g.RectFill(Win.rPort,ox+23*sx-1,oy+9*sy-1,ox+30*sx+1,oy+11*sy+1);
  346.  FOR n:=0 TO 3 DO
  347.   m:=t MOD 10;
  348.   RenderNum(2,m,-1,-1,8-n);
  349.   RenderNum(1,m,1,1,8-n);
  350.   RenderNum(0,m,0,0,8-n);
  351.   t:=t DIV 10;
  352.  END;
  353. END RenderHScor;
  354.  
  355. PROCEDURE RenderScor;
  356. VAR n,m,t:INTEGER;
  357. BEGIN;
  358.  t:=scor;
  359.  g.SetAPen(Win.rPort,0);
  360.  g.RectFill(Win.rPort,ox+13*sx-1,oy+9*sy-1,ox+20*sx+1,oy+11*sy+1);
  361.  FOR n:=0 TO 3 DO
  362.   m:=t MOD 10;
  363.   RenderNum(2,m,-1,-1,3-n);
  364.   RenderNum(1,m,1,1,3-n);
  365.   RenderNum(3,m,0,0,3-n);
  366.   t:=t DIV 10;
  367.  END;
  368. END RenderScor;
  369.  
  370. PROCEDURE RedrawWin;
  371. BEGIN;
  372. CalcWin;
  373. g.SetAPen(Win.rPort,0);
  374. g.RectFill(Win.rPort,ox,oy,Win.width-Win.borderRight-1,Win.height-Win.borderBottom-1);
  375. RenderBorders;
  376. RenderTiles;
  377. RenderNext;
  378. RenderBonus;
  379. RenderScor;
  380. RenderHScor;
  381. END RedrawWin;
  382.  
  383. PROCEDURE ShowHelp;
  384. VAR f:fs.File;
  385.     t:strg;
  386. BEGIN;
  387. IF fs.Open(f,helpname,FALSE) THEN
  388.  WHILE fs.ReadString(f,t) DO
  389.   io.WriteString(t);io.WriteLn;
  390.  END;
  391.  IF fs.Close(f) THEN END;
  392. END;
  393. END ShowHelp;
  394.  
  395. PROCEDURE Loop;
  396. VAR ims,ims2:I.IntuiMessagePtr;
  397.     quit,over,al:BOOLEAN;
  398.     xp,yp,id,k:INTEGER;
  399. BEGIN;
  400. quit:=FALSE;over:=TRUE;
  401. WHILE ~quit DO
  402. Smsg:=2;UpdMsg;
  403. RenderHScor;
  404. WHILE (~quit)AND(over) DO
  405.  ims:=e.GetMsg(Win.userPort)(I.IntuiMessagePtr);
  406.  IF ims=NIL THEN
  407.   e.WaitPort(Win.userPort);
  408.  ELSE
  409.   IF I.closeWindow IN ims.class THEN quit:=TRUE;END;
  410.   IF I.newSize IN ims.class THEN RedrawWin;END;
  411.   IF I.mouseButtons IN ims.class THEN over:=FALSE;END;
  412.   e.ReplyMsg(ims);
  413.  END;
  414. END;
  415. FOR k:=0 TO 4 DO FOR id:=0 TO 4 DO sets[id,k]:=-1;END;END;
  416. timf:=30;bonus:=5;
  417. CalcWin;
  418. NewTile;
  419. tim:=1500;timo:=1500;scor:=0;
  420. Smsg:=0;Smsgo:=-1;
  421. RedrawWin;
  422. WHILE (~quit)AND(~over) DO
  423.  id:=-1;
  424.  ims:=e.GetMsg(Win.userPort)(I.IntuiMessagePtr);
  425.  IF ims=NIL THEN
  426.   e.WaitPort(Win.userPort);
  427.  ELSE
  428.   IF I.closeWindow IN ims.class THEN quit:=TRUE;END;
  429.   IF I.newSize IN ims.class THEN RedrawWin;END;
  430.   IF I.inactiveWindow IN ims.class THEN
  431.    I.SetWindowTitles(Win,y.ADR("Paused..."),-1);
  432.    Smsgo:=-1;
  433.    CalcWin;
  434.        g.SetAPen(Win.rPort,0);
  435.        g.RectFill(Win.rPort,ox,oy,Win.width-Win.borderRight-1,Win.height-Win.borderBottom-1);
  436.        RenderBorders;
  437.        RenderBonus;
  438.        RenderHScor;
  439.        RenderScor;
  440.    al:=FALSE;
  441.    REPEAT;
  442.     ims2:=e.GetMsg(Win.userPort)(I.IntuiMessagePtr);
  443.     IF ims2=NIL THEN
  444.      e.WaitPort(Win.userPort);
  445.     ELSE
  446.      IF I.mouseButtons IN ims2.class THEN al:=TRUE; END;
  447.      IF I.closeWindow IN ims2.class THEN al:=TRUE;quit:=TRUE;END;
  448.      IF I.newSize IN ims2.class THEN CalcWin;
  449.        g.SetAPen(Win.rPort,0);
  450.        g.RectFill(Win.rPort,ox,oy,Win.width-Win.borderRight-1,Win.height-Win.borderBottom-1);
  451.        RenderBorders;
  452.        RenderBonus;
  453.        RenderHScor;
  454.        RenderScor;
  455.      END;
  456.      e.ReplyMsg(ims2);
  457.     END;
  458.    UNTIL al;
  459.    RedrawWin;
  460.   END;
  461.   IF I.intuiTicks IN ims.class THEN
  462.    timo:=tim;tim:=tim+timf;
  463.    RenderClock;
  464.    IF tim>3500 THEN
  465.     timo:=tim;tim:=1500;
  466.     RenderClock;
  467.     DEC(bonus);
  468.     RenderBonus;
  469.     NewTile;
  470.     IF bonus<1 THEN over:=TRUE;Smsg:=3;IF scor>high THEN high:=scor;END;END;
  471.    END;
  472.   END;
  473.   UpdMsg;
  474.   IF I.mouseButtons IN ims.class THEN
  475.    IF (ims.code=233) THEN
  476.     ShowHelp;
  477.    END;
  478.    IF (ims.code=232)AND(ims.mouseX>ox) THEN
  479.     xp:=(ims.mouseX-ox) DIV sx;
  480.     yp:=(ims.mouseY-oy) DIV sy;
  481.     IF (yp>0)AND(yp<6) THEN
  482.      IF (xp MOD 6 >0) AND (xp <30) THEN
  483.       id:=xp DIV 6;
  484.       IF sets[id,ns]=-1 THEN
  485.        IF (scor>50)AND(timf<110) THEN Smsg:=1;INC(timf);END;
  486.        IF timf=110 THEN Smsg:=0;END;
  487.        INC(scor);
  488.        RenderScor;
  489.        sets[id,ns]:=nc;
  490.        timo:=tim;tim:=1500;
  491.        RenderClock;
  492.        al:=TRUE;
  493.        FOR k:=0 TO 4 DO
  494.         IF sets[id,k]=-1 THEN al:=FALSE;END;
  495.        END;
  496.        IF al THEN
  497.         IF (sets[id,0]=sets[id,1])AND
  498.            (sets[id,0]=sets[id,2])AND
  499.            (sets[id,0]=sets[id,3])AND
  500.            (sets[id,0]=sets[id,4])AND
  501.            (bonus<17)
  502.          THEN
  503.          INC(bonus);
  504.         END;
  505.         FOR k:=0 TO 4 DO sets[id,k]:=-1;END;
  506.        END;
  507.        RenderTiles;
  508.        RenderBonus;
  509.        NewTile;
  510.       END;
  511.      END;
  512.     END;
  513.    END;
  514.   END;
  515.   e.ReplyMsg(ims);
  516.  END;
  517. END;
  518. END;
  519. Save;
  520. END Loop;
  521.  
  522.  
  523.  
  524. BEGIN;
  525. Init;ns:=0;nc:=-1;
  526. RedrawWin;
  527. Loop;
  528. CLOSE;
  529. I.CloseWindow(Win);
  530. END SortTiles.
  531.  
  532.